<template>
    <div class="body">
        <div id="qrcode" ref="qrcode" class="qrcode">
            <p>我的分享二维码</p>
        </div>
    </div>
</template>
<script>
import QRCode from 'qrcodejs2'
export default {
    data() {
        return {
           user: null 
        }
    },
    mounted(){
        this.user = this.$store.getters.wxUserInfo;
        let qrcode = new QRCode('qrcode', {
            width: 150, //图像宽度
            height: 150, //图像高度
            colorDark : "#000000", //前景色
            colorLight : "#ffffff", //背景色
            typeNumber:4, 
            text: `${window.location.href}?admin_id=${this.user.admin_id}&state=${this.user.code}`,
            correctLevel : QRCode.CorrectLevel.H //容错级别 容错级别有：（1）QRCode.CorrectLevel.L （2）QRCode.CorrectLevel.M （3）QRCode.CorrectLevel.Q （4）QRCode.CorrectLevel.H
        })
    }
}
</script>
<style lang="scss" scoped>
    :before{
        display: table; 
        content: "";
    }
    .body{
        background: #eee;
        height: calc(100vh - 3rem);
        .qrcode{
            width: 12rem;
            height: 16rem;
            margin: auto;
            text-align: center;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            margin-top: 2rem;
            padding: 1rem;
            line-height: 2rem;
            border-radius: 1rem;
            background: #fff;
        }
    }
</style>